package com.simon.samples.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.simon.samples.client.IncorrectUserOrPassword;
import com.simon.samples.client.LoginService;
import com.simon.samples.client.SessionID;

public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
//com.simon.samples.server.LoginServiceImpl

	/**
	 * 
	 */
	private static final long serialVersionUID = 1661204435912047040L;
	@Override
	public SessionID login(String username, String password) throws IncorrectUserOrPassword {
		try {
			if(DataBaseConnection.testUserPassword(username,password)){
				return new SessionID("0000", 666);
			}
			else{
				throw new IncorrectUserOrPassword(username,password);
			}
		} catch (Exception e) {
			throw new IncorrectUserOrPassword("ERROR","ERROR");
		}
	}

}
